﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace WhileAwayWpf
{
    class Win32
    {
        private const int WM_SYSCOMMAND = 0x0112;
        private const int SC_SCREENSAVE = 0xF140;

        [DllImport("user32.dll", EntryPoint = "GetDesktopWindow")]
        private static extern IntPtr GetDesktopWindow();

        [DllImport("user32.dll",CharSet=CharSet.Auto)]  
        private static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, int lParam);

        public static void ActivateScreensaver()
        {
            IntPtr desktop = GetDesktopWindow();
            long lngResult = SendMessage(desktop, WM_SYSCOMMAND, SC_SCREENSAVE, 0);
        }

    }
}
